From 35494f5d081a4f726631df3beee3bdc7d9a8b41e Mon Sep 17 00:00:00 2001 From: =?utf8?q?Florian=20M=C3=BCllner?= Date: Tue, 17 Dec 2019 01:01:13 +0100 Subject: [PATCH] popupMenu: Close when source actor gets hidden If a menu is anchored to a source actor, it is odd to leave it floating around when the source actor gets hidden. Close the menu instead in that case. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2002 --- js/ui/popupMenu.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index c3e763b36..56638050f 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -814,7 +814,12 @@ var PopupMenu = class extends PopupMenuBase { if (this.sourceActor) { this._keyPressId = this.sourceActor.connect('key-press-event', - this._onKeyPress.bind(this)); + this._onKeyPress.bind(this)); + this._notifyMappedId = this.sourceActor.connect('notify::mapped', + () => { + if (!this.sourceActor.mapped) + this.close(); + }); } this._systemModalOpenedId = 0; @@ -928,6 +933,9 @@ var PopupMenu = class extends PopupMenuBase { if (this._keyPressId) this.sourceActor.disconnect(this._keyPressId); + if (this._notifyMappedId) + this.sourceActor.disconnect(this._notifyMappedId); + if (this._systemModalOpenedId) Main.layoutManager.disconnect(this._systemModalOpenedId); this._systemModalOpenedId = 0; -- 2.39.5